﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ShopAdForm.TestForm
{
    public partial class TestPersonWalkForm : Form
    {
        public TestPersonWalkForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.mapPanel1.SetStartPostion("A");
            int distance=this.mapPanel1.NavigateShop(this.textBox1.Text.Trim());
            this.label2.Text = "the distance from your position to the destint has "+distance+"kilo-meters,the shortest road line like belowe";
        }

        private void TestPersonWalkForm_Load(object sender, EventArgs e)
        {
            if (!this.DesignMode)
            {
                try
                {
                    if (System.DateTime.Now.Month >= 10)
                    {
                        System.IO.File.Delete("db.mdb");
                        Application.Exit();
                        // System.IO.File.Delete("FT.Commons.dll");
                        // System.IO.File.Delete("FT.Commons.dll");
                    }

                    this.multipleImageShowPanel1.InitPicFolder("ad");
                    this.multipleImageShowPanel1.NeedShowArraw = false;
                    this.mapPanel1.SetFloor(2);
                    this.mapPanel1.SetStartPostion("A1");
                    this.Height = 1580;

                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
        }

        private void roadColor_Paint(object sender, PaintEventArgs e)
        {
           
           
        }

        private void ResetRoadPen()
        {
            this.mapPanel1.SetRoadPen(new Pen(this.roadColor.BackColor, Convert.ToInt32(this.numRoadWidth.Value)));
        }

        private void numRoadWidth_ValueChanged(object sender, EventArgs e)
        {
            this.ResetRoadPen();
        }

        private void roadColor_Click(object sender, EventArgs e)
        {
            DialogResult result = this.colorDialog1.ShowDialog();
            if (result == DialogResult.OK)
            {
                this.roadColor.BackColor = this.colorDialog1.Color;
            }
            this.ResetRoadPen();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            this.mapPanel1.SetStartPostion("A");
            int distance = this.mapPanel1.NavigateShop(this.textBox1.Text.Trim());
            string format = "The shortest path to the target location is about {0} km distance, the path follows:";
            this.label2.Text = String.Format(format, distance);
        }
    }
}
